import Mock from 'mockjs2'
import { builder } from '../util'

const info = options => {
  console.log('options', options)
  const userInfo = {
    id: '4291d7da9005377ec9aec4a71ea837f',
    name: '李酉夏',
    username: 'admin',
    password: '',
    avatar: '/avatar2.jpg',
    status: 1,
    telephone: '',
    lastLoginIp: '27.154.74.117',
    lastLoginTime: 1534837621348,
    creatorId: 'admin',
    createTime: 1497160610259,
    merchantCode: 'TLif2btpzg079h15bk',
    deleted: 0,
    roleId: 'admin',
    role: {}
  }
  // role
  const roleObj = {
    id: 'admin',
    name: '管理员',
    describe: '拥有所有权限',
    status: 1,
    creatorId: 'system',
    createTime: 1497160610259,
    deleted: 0,
    permissions: [
      {
        roleId: 'admin',
        permissionId: 'dashboard',
        permissionName: '仪表盘',
        actions:
          '[{"action":"add","defaultCheck":false,"describe":"新增"},{"action":"query","defaultCheck":false,"describe":"查询"},{"action":"get","defaultCheck":false,"describe":"详情"},{"action":"update","defaultCheck":false,"describe":"修改"},{"action":"delete","defaultCheck":false,"describe":"删除"}]',
        actionEntitySet: [
          {
            action: 'add',
            describe: '新增',
            defaultCheck: false
          },
          {
            action: 'query',
            describe: '查询',
            defaultCheck: false
          },
          {
            action: 'get',
            describe: '详情',
            defaultCheck: false
          },
          {
            action: 'update',
            describe: '修改',
            defaultCheck: false
          },
          {
            action: 'delete',
            describe: '删除',
            defaultCheck: false
          }
        ],
        actionList: null,
        dataAccess: null
      },
      {
        roleId: 'admin',
        permissionId: 'exception',
        permissionName: '异常页面权限',
        actions:
          '[{"action":"add","defaultCheck":false,"describe":"新增"},{"action":"query","defaultCheck":false,"describe":"查询"},{"action":"get","defaultCheck":false,"describe":"详情"},{"action":"update","defaultCheck":false,"describe":"修改"},{"action":"delete","defaultCheck":false,"describe":"删除"}]',
        actionEntitySet: [
          {
            action: 'add',
            describe: '新增',
            defaultCheck: false
          },
          {
            action: 'query',
            describe: '查询',
            defaultCheck: false
          },
          {
            action: 'get',
            describe: '详情',
            defaultCheck: false
          },
          {
            action: 'update',
            describe: '修改',
            defaultCheck: false
          },
          {
            action: 'delete',
            describe: '删除',
            defaultCheck: false
          }
        ],
        actionList: null,
        dataAccess: null
      },
      {
        roleId: 'admin',
        permissionId: 'result',
        permissionName: '结果权限',
        actions:
          '[{"action":"add","defaultCheck":false,"describe":"新增"},{"action":"query","defaultCheck":false,"describe":"查询"},{"action":"get","defaultCheck":false,"describe":"详情"},{"action":"update","defaultCheck":false,"describe":"修改"},{"action":"delete","defaultCheck":false,"describe":"删除"}]',
        actionEntitySet: [
          {
            action: 'add',
            describe: '新增',
            defaultCheck: false
          },
          {
            action: 'query',
            describe: '查询',
            defaultCheck: false
          },
          {
            action: 'get',
            describe: '详情',
            defaultCheck: false
          },
          {
            action: 'update',
            describe: '修改',
            defaultCheck: false
          },
          {
            action: 'delete',
            describe: '删除',
            defaultCheck: false
          }
        ],
        actionList: null,
        dataAccess: null
      },
      {
        roleId: 'admin',
        permissionId: 'profile',
        permissionName: '详细页权限',
        actions:
          '[{"action":"add","defaultCheck":false,"describe":"新增"},{"action":"query","defaultCheck":false,"describe":"查询"},{"action":"get","defaultCheck":false,"describe":"详情"},{"action":"update","defaultCheck":false,"describe":"修改"},{"action":"delete","defaultCheck":false,"describe":"删除"}]',
        actionEntitySet: [
          {
            action: 'add',
            describe: '新增',
            defaultCheck: false
          },
          {
            action: 'query',
            describe: '查询',
            defaultCheck: false
          },
          {
            action: 'get',
            describe: '详情',
            defaultCheck: false
          },
          {
            action: 'update',
            describe: '修改',
            defaultCheck: false
          },
          {
            action: 'delete',
            describe: '删除',
            defaultCheck: false
          }
        ],
        actionList: null,
        dataAccess: null
      },
      {
        roleId: 'admin',
        permissionId: 'table',
        permissionName: '表格权限',
        actions:
          '[{"action":"add","defaultCheck":false,"describe":"新增"},{"action":"import","defaultCheck":false,"describe":"导入"},{"action":"get","defaultCheck":false,"describe":"详情"},{"action":"update","defaultCheck":false,"describe":"修改"}]',
        actionEntitySet: [
          {
            action: 'add',
            describe: '新增',
            defaultCheck: false
          },
          {
            action: 'import',
            describe: '导入',
            defaultCheck: false
          },
          {
            action: 'get',
            describe: '详情',
            defaultCheck: false
          },
          {
            action: 'update',
            describe: '修改',
            defaultCheck: false
          }
        ],
        actionList: null,
        dataAccess: null
      },
      {
        roleId: 'admin',
        permissionId: 'form',
        permissionName: '表单权限',
        actions:
          '[{"action":"add","defaultCheck":false,"describe":"新增"},{"action":"get","defaultCheck":false,"describe":"详情"},{"action":"query","defaultCheck":false,"describe":"查询"},{"action":"update","defaultCheck":false,"describe":"修改"},{"action":"delete","defaultCheck":false,"describe":"删除"}]',
        actionEntitySet: [
          {
            action: 'add',
            describe: '新增',
            defaultCheck: false
          },
          {
            action: 'get',
            describe: '详情',
            defaultCheck: false
          },
          {
            action: 'query',
            describe: '查询',
            defaultCheck: false
          },
          {
            action: 'update',
            describe: '修改',
            defaultCheck: false
          },
          {
            action: 'delete',
            describe: '删除',
            defaultCheck: false
          }
        ],
        actionList: null,
        dataAccess: null
      },
      {
        roleId: 'admin',
        permissionId: 'order',
        permissionName: '订单管理',
        actions:
          '[{"action":"add","defaultCheck":false,"describe":"新增"},{"action":"query","defaultCheck":false,"describe":"查询"},{"action":"get","defaultCheck":false,"describe":"详情"},{"action":"update","defaultCheck":false,"describe":"修改"},{"action":"delete","defaultCheck":false,"describe":"删除"}]',
        actionEntitySet: [
          {
            action: 'add',
            describe: '新增',
            defaultCheck: false
          },
          {
            action: 'query',
            describe: '查询',
            defaultCheck: false
          },
          {
            action: 'get',
            describe: '详情',
            defaultCheck: false
          },
          {
            action: 'update',
            describe: '修改',
            defaultCheck: false
          },
          {
            action: 'delete',
            describe: '删除',
            defaultCheck: false
          }
        ],
        actionList: null,
        dataAccess: null
      },
      {
        roleId: 'admin',
        permissionId: 'permission',
        permissionName: '权限管理',
        actions:
          '[{"action":"add","defaultCheck":false,"describe":"新增"},{"action":"get","defaultCheck":false,"describe":"详情"},{"action":"update","defaultCheck":false,"describe":"修改"},{"action":"delete","defaultCheck":false,"describe":"删除"}]',
        actionEntitySet: [
          {
            action: 'add',
            describe: '新增',
            defaultCheck: false
          },
          {
            action: 'get',
            describe: '详情',
            defaultCheck: false
          },
          {
            action: 'update',
            describe: '修改',
            defaultCheck: false
          },
          {
            action: 'delete',
            describe: '删除',
            defaultCheck: false
          }
        ],
        actionList: null,
        dataAccess: null
      },
      {
        roleId: 'admin',
        permissionId: 'role',
        permissionName: '角色管理',
        actions:
          '[{"action":"add","defaultCheck":false,"describe":"新增"},{"action":"get","defaultCheck":false,"describe":"详情"},{"action":"update","defaultCheck":false,"describe":"修改"},{"action":"delete","defaultCheck":false,"describe":"删除"}]',
        actionEntitySet: [
          {
            action: 'add',
            describe: '新增',
            defaultCheck: false
          },
          {
            action: 'get',
            describe: '详情',
            defaultCheck: false
          },
          {
            action: 'update',
            describe: '修改',
            defaultCheck: false
          },
          {
            action: 'delete',
            describe: '删除',
            defaultCheck: false
          }
        ],
        actionList: null,
        dataAccess: null
      },
      {
        roleId: 'admin',
        permissionId: 'table',
        permissionName: '桌子管理',
        actions:
          '[{"action":"add","defaultCheck":false,"describe":"新增"},{"action":"get","defaultCheck":false,"describe":"详情"},{"action":"query","defaultCheck":false,"describe":"查询"},{"action":"update","defaultCheck":false,"describe":"修改"},{"action":"delete","defaultCheck":false,"describe":"删除"}]',
        actionEntitySet: [
          {
            action: 'add',
            describe: '新增',
            defaultCheck: false
          },
          {
            action: 'get',
            describe: '详情',
            defaultCheck: false
          },
          {
            action: 'query',
            describe: '查询',
            defaultCheck: false
          },
          {
            action: 'update',
            describe: '修改',
            defaultCheck: false
          },
          {
            action: 'delete',
            describe: '删除',
            defaultCheck: false
          }
        ],
        actionList: null,
        dataAccess: null
      },
      {
        roleId: 'admin',
        permissionId: 'user',
        permissionName: '用户管理',
        actions:
          '[{"action":"add","defaultCheck":false,"describe":"新增"},{"action":"import","defaultCheck":false,"describe":"导入"},{"action":"get","defaultCheck":false,"describe":"详情"},{"action":"update","defaultCheck":false,"describe":"修改"},{"action":"delete","defaultCheck":false,"describe":"删除"},{"action":"export","defaultCheck":false,"describe":"导出"}]',
        actionEntitySet: [
          {
            action: 'add',
            describe: '新增',
            defaultCheck: false
          },
          {
            action: 'import',
            describe: '导入',
            defaultCheck: false
          },
          {
            action: 'get',
            describe: '详情',
            defaultCheck: false
          },
          {
            action: 'update',
            describe: '修改',
            defaultCheck: false
          },
          {
            action: 'delete',
            describe: '删除',
            defaultCheck: false
          },
          {
            action: 'export',
            describe: '导出',
            defaultCheck: false
          }
        ],
        actionList: null,
        dataAccess: null
      }
    ]
  }

  roleObj.permissions.push({
    roleId: 'admin',
    permissionId: 'support',
    permissionName: '超级模块',
    actions:
      '[{"action":"add","defaultCheck":false,"describe":"新增"},{"action":"import","defaultCheck":false,"describe":"导入"},{"action":"get","defaultCheck":false,"describe":"详情"},{"action":"update","defaultCheck":false,"describe":"修改"},{"action":"delete","defaultCheck":false,"describe":"删除"},{"action":"export","defaultCheck":false,"describe":"导出"}]',
    actionEntitySet: [
      {
        action: 'add',
        describe: '新增',
        defaultCheck: false
      },
      {
        action: 'import',
        describe: '导入',
        defaultCheck: false
      },
      {
        action: 'get',
        describe: '详情',
        defaultCheck: false
      },
      {
        action: 'update',
        describe: '修改',
        defaultCheck: false
      },
      {
        action: 'delete',
        describe: '删除',
        defaultCheck: false
      },
      {
        action: 'export',
        describe: '导出',
        defaultCheck: false
      }
    ],
    actionList: null,
    dataAccess: null
  })

  userInfo.role = roleObj
  return builder(userInfo)
}

const userNav = options => {
  const nav = [
    // dashboard
    {
      name: 'dashboard',
      parentId: 0,
      id: 1,
      meta: {
        icon: 'dashboard',
        title: '管理员管理',
        show: true
      },
      component: 'RouteView',
      hideChildrenInMenu: true,
      redirect: '/dashboard/workplace'
    },
    {
      name: 'workplace',
      parentId: 1,
      id: 7,
      meta: {
        icon: 'dashboard',
        title: '管理员管理',
        show: true,
        hiddenHeaderContent: true
      },
      component: 'Workplace'
    },
     // profile
    {
      name: 'profile',
      parentId: 0,
      id: 10018,
      meta: {
        title: '用户管理',
        icon: 'form',
        show: true
      },
      component: 'RouteView',
      redirect: '/profile/advanced'
    },
    {
      name: 'advanced',
      parentId: 10018,
      id: 10020,
      meta: {
        title: '用户管理',
        show: true
      },
      component: 'ProfileAdvanced'
    },
    {
      name: 'article',
      parentId: 10020,
      id: 10015,
      meta: {
        title: '待审核',
        show: true
      },
      component: 'SearchArticlesA'
    },
    {
      name: 'project',
      parentId: 10020,
      id: 10016,
      meta: {
        title: '已审核',
        show: true
      },
      component: 'SearchProjectsB'
    },
    {
      name: 'application',
      parentId: 10020,
      id: 10017,
      meta: {
        title: '提现账单',
        show: true
      },
      component: 'SearchApplicationsC'
    },
    // taskManagement
    {
      name: 'taskManagement',
      parentId: 0,
      id: 10010,
      meta: {
        icon: 'table',
        title: '任务管理',
        show: true
      },
      redirect: '/taskManagement/gatherTask',
      component: 'RouteView'
    },
    {
      // name属性很重要 与URL直接相关
      name: 'gatherTask',
      parentId: 10010,
      id: 10021,
      meta: {
        title: '采集任务',
        show: true
      },
      component: 'TaskManagement'
    },
    {
      name: 'taskAwaited',
      parentId: 10021,
      id: 10013,
      meta: {
        title: '待审核',
        show: true
      },
      component: 'CardList3A'
    },
    // id和component有无特定联系
    {
      name: 'taskChecked',
      parentId: 10021,
      id: 10015,
      meta: {
        title: '已审核',
        show: true
      },
      component: 'StandardList3B'
    },
    {
      name: 'teachTask',
      parentId: 10010,
      id: 10014,
      meta: {
        title: '教学任务',
        show: true
      },
      component: 'StandardList3C'
    },
    {
      name: 'statementManagement',
      parentId: 0,
      id: 10,
      meta: {
        icon: 'profile',
        title: '语句管理',
        show: true
      },
      redirect: '/statementManagement/statement',
      component: 'RouteView'
    },
    {
      name: 'statement',
      parentId: 10,
      id: 10012,
      meta: {
        title: '语句管理',
        show: true
      },
      component: 'StatementManagement'
    },
    {
      name: 'WordsManage',
      parentId: 10012,
      id: 10016,
      meta: {
        title: '词组',
        show: true
      },
      component: 'WordsManage'
    },
    // id和component有无特定联系
    {
      name: 'StatementsManage',
      parentId: 10012,
      id: 10019,
      meta: {
        title: '语句',
        show: true
      },
      component: 'StatementsManage'
    }
    // {
    //   name: 'step-form',
    //   parentId: 10,
    //   id: 5,
    //   meta: {
    //     title: '分步表单'
    //   },
    //   component: 'StepForm'
    // },
    // {
    //   name: 'advanced-form',
    //   parentId: 10,
    //   id: 4,
    //   meta: {
    //     title: '高级表单'
    //   },
    //   component: 'AdvanceForm'
    // }
    // result
    // {
    //   name: 'result',
    //   parentId: 0,
    //   id: 10021,
    //   meta: {
    //     title: '语句管理',
    //     icon: 'check-circle-o',
    //     show: true
    //   },
    //   redirect: '/result/success',
    //   component: 'PageView'
    // },
    // {
    //   name: 'success',
    //   parentId: 10021,
    //   id: 10022,
    //   meta: {
    //     title: '成功',
    //     hiddenHeaderContent: true,
    //     show: true
    //   },
    //   component: 'ResultSuccess'
    // },
    // {
    //   name: 'fail',
    //   parentId: 10021,
    //   id: 10023,
    //   meta: {
    //     title: '失败',
    //     hiddenHeaderContent: true,
    //     show: true
    //   },
    //   component: 'ResultFail'
    // }
    // Exception
    // {
    //   name: 'exception',
    //   parentId: 0,
    //   id: 10024,
    //   meta: {
    //     title: '异常页',
    //     icon: 'warning',
    //     show: true
    //   },
    //   redirect: '/exception/403',
    //   component: 'RouteView'
    // },
    // {
    //   name: '403',
    //   parentId: 10024,
    //   id: 10025,
    //   meta: {
    //     title: '403',
    //     show: true
    //   },
    //   component: 'Exception403'
    // },
    // {
    //   name: '404',
    //   parentId: 10024,
    //   id: 10026,
    //   meta: {
    //     title: '404',
    //     show: true
    //   },
    //   component: 'Exception404'
    // },
    // {
    //   name: '500',
    //   parentId: 10024,
    //   id: 10027,
    //   meta: {
    //     title: '500',
    //     show: true
    //   },
    //   component: 'Exception500'
    // },
    // account
    // {
    //   name: 'account',
    //   parentId: 0,
    //   id: 10028,
    //   meta: {
    //     title: '个人页',
    //     icon: 'user',
    //     show: true
    //   },
    //   redirect: '/account/center',
    //   component: 'RouteView'
    // },
    // {
    //   name: 'center',
    //   parentId: 10028,
    //   id: 10029,
    //   meta: {
    //     title: '个人中心',
    //     show: true
    //   },
    //   component: 'AccountCenter'
    // },
    // // 特殊三级菜单
    // {
    //   name: 'settings',
    //   parentId: 10028,
    //   id: 10030,
    //   meta: {
    //     title: '个人设置',
    //     hideHeader: true,
    //     hideChildren: true,
    //     show: true
    //   },
    //   redirect: '/account/settings/base',
    //   component: 'AccountSettings'
    // },
    // {
    //   name: 'BasicSetting',
    //   path: '/account/settings/base',
    //   parentId: 10030,
    //   id: 10031,
    //   meta: {
    //     title: '基本设置',
    //     show: false
    //   },
    //   component: 'BasicSetting'
    // },
    // {
    //   name: 'SecuritySettings',
    //   path: '/account/settings/security',
    //   parentId: 10030,
    //   id: 10032,
    //   meta: {
    //     title: '安全设置',
    //     show: false
    //   },
    //   component: 'SecuritySettings'
    // },
    // {
    //   name: 'CustomSettings',
    //   path: '/account/settings/custom',
    //   parentId: 10030,
    //   id: 10033,
    //   meta: {
    //     title: '个性化设置',
    //     show: false
    //   },
    //   component: 'CustomSettings'
    // },
    // {
    //   name: 'BindingSettings',
    //   path: '/account/settings/binding',
    //   parentId: 10030,
    //   id: 10034,
    //   meta: {
    //     title: '账户绑定',
    //     show: false
    //   },
    //   component: 'BindingSetting'
    // },
    // {
    //   name: 'NotificationSettings',
    //   path: '/account/settings/notification',
    //   parentId: 10030,
    //   id: 10034,
    //   meta: {
    //     title: '新消息通知',
    //     show: false
    //   },
    //   component: 'NotificationSettings'
    // }
  ]
  const json = builder(nav)
  console.log('json', json)
  return json
}

Mock.mock(/\/api\/user\/info/, 'get', info)
Mock.mock(/\/api\/user\/nav/, 'get', userNav)
